// 记账相关的类型定义
// import type { FamilyMemberResponse } from './family'

// 交易类型
export type TransactionType = "income" | "expense" | "transfer";

// 账户类型
export type AccountType =
  | "cash"
  | "bank"
  | "credit_card"
  | "alipay"
  | "wechat"
  | "other";

// 分类类型
export type CategoryType = "income" | "expense";

// 分类响应
export interface CategoryResponse {
  id: number;
  name: string;
  parent_id?: number | null;
  icon?: string | null;
  color?: string | null;
  sort_order: number;
  family_id: number;
  is_system: boolean;
  created_at: string;
  updated_at?: string | null;
  family_name?: string | null;
  parent_name?: string | null;
}

// 分类创建
export interface CategoryCreate {
  name: string;
  parent_id?: number | null;
  icon?: string | null;
  color?: string | null;
  sort_order?: number;
}

// 分类更新
export interface CategoryUpdate {
  name?: string | null;
  parent_id?: number | null;
  icon?: string | null;
  color?: string | null;
  sort_order?: number | null;
}

// 带子分类的分类
export interface CategoryWithChildren extends CategoryResponse {
  children: CategoryWithChildren[];
}

// 批量分类创建
export interface BatchCategoryCreate {
  categories: CategoryCreate[];
}

// 账户响应
export interface AccountResponse {
  id: number;
  name: string;
  account_type: AccountType;
  balance: string;
  initial_balance: string;
  icon?: string | null;
  color?: string | null;
  description?: string | null;
  family_id: number;
  is_active: boolean;
  created_at: string;
  updated_at?: string | null;
  family_name?: string | null;
}

// 账户创建
export interface AccountCreate {
  name: string;
  account_type: AccountType;
  initial_balance?: string;
  icon?: string | null;
  color?: string | null;
  description?: string | null;
}

// 账户更新
export interface AccountUpdate {
  name?: string | null;
  account_type?: AccountType | null;
  icon?: string | null;
  color?: string | null;
  description?: string | null;
  is_active?: boolean | null;
}

// 项目响应
export interface ProjectResponse {
  id: number;
  name: string;
  description?: string | null;
  start_date?: string | null;
  end_date?: string | null;
  budget?: string | null;
  color?: string | null;
  family_id: number;
  is_active: boolean;
  created_at: string;
  updated_at?: string | null;
  family_name?: string | null;
}

// 项目创建
export interface ProjectCreate {
  name: string;
  description?: string | null;
  start_date?: string | null;
  end_date?: string | null;
  budget?: string | null;
  color?: string | null;
}

// 项目更新
export interface ProjectUpdate {
  name?: string | null;
  description?: string | null;
  start_date?: string | null;
  end_date?: string | null;
  budget?: string | null;
  color?: string | null;
  is_active?: boolean | null;
}

// 交易响应
export interface TransactionResponse {
  id: number;
  transaction_type: TransactionType;
  amount: string;
  description?: string | null;
  transaction_date: string;
  account_id: number;
  category_id?: number | null;
  to_account_id?: number | null;
  project_id?: number | null;
  member_id?: number | null;
  is_recurring: boolean;
  recurring_pattern?: string | null;
  tags?: string | null;
  receipt_image?: string | null;
  family_id: number;
  is_deleted: boolean;
  created_at: string;
  updated_at?: string | null;
  family_name?: string | null;
  category_name?: string | null;
  account_name?: string | null;
  to_account_name?: string | null;
  project_name?: string | null;
  member_name?: string | null;
}

// 交易创建
export interface TransactionCreate {
  transaction_type: TransactionType;
  amount: string;
  description?: string | null;
  transaction_date: string;
  account_id: number;
  category_id?: number | null;
  to_account_id?: number | null;
  project_id?: number | null;
  member_id?: number | null;
  is_recurring: boolean;
  recurring_pattern?: string | null;
  tags?: string | null;
  receipt_image?: string | null;
}

// 交易更新
export interface TransactionUpdate {
  transaction_type?: TransactionType | null;
  amount?: string | null;
  description?: string | null;
  transaction_date?: string | null;
  account_id?: number | null;
  category_id?: number | null;
  to_account_id?: number | null;
  project_id?: number | null;
  member_id?: number | null;
  is_recurring?: boolean | null;
  recurring_pattern?: string | null;
  tags?: string | null;
  receipt_image?: string | null;
}

// 批量交易创建
export interface BatchTransactionCreate {
  transactions: TransactionCreate[];
}

// 交易列表响应
export interface TransactionList {
  transactions: TransactionResponse[];
  total: number;
  skip: number;
  limit: number;
}

// 交易摘要
export interface TransactionSummary {
  total_income: string;
  total_expense: string;
  total_transfer: string;
  net_income: string;
  transaction_count: number;
}

// 分类统计
export interface CategorySummary {
  category_id: number;
  category_name: string;
  total_amount: string;
  transaction_count: number;
}

// 账户统计
export interface AccountSummary {
  account_id: number;
  account_name: string;
  balance: string;
  income_amount: string;
  expense_amount: string;
  transaction_count: number;
}

// 项目统计
export interface ProjectSummary {
  project_id: number;
  project_name: string;
  budget?: string | null;
  expense_amount: string;
  transaction_count: number;
  remaining_budget?: string | null;
}

// 查询参数
export interface TransactionListParams {
  transaction_type?: TransactionType | null;
  account_id?: number | null;
  category_id?: number | null;
  project_id?: number | null;
  member_id?: number | null;
  start_date?: string | null;
  end_date?: string | null;
  search?: string | null;
  skip?: number;
  limit?: number;
}

export interface CategoryListParams {
  parent_id?: number | null;
  skip?: number;
  limit?: number;
}

export interface AccountListParams {
  is_active?: boolean | null;
  account_type?: AccountType | null;
  skip?: number;
  limit?: number;
}

export interface ProjectListParams {
  is_active?: boolean | null;
  skip?: number;
  limit?: number;
}

export interface StatisticsParams {
  start_date?: string | null;
  end_date?: string | null;
}
